﻿using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using BBI.Model;
//using BBICMS.Data.SampleData;

namespace BBI.Data
{
    public class ArticleDbContext : DbContext 
    {
  
        public static string ConnectionStringName
        {
            get
            {
                if (BBI.Infrastructure.Globals.Settings.DefaultConnectionStringName
                    != null)
                {
                    return BBI.Infrastructure.Globals.Settings.DefaultConnectionStringName.ToString();
                }
                return "DefaultConnection";
            }
        }
        public ArticleDbContext()
            : base(nameOrConnectionString: ArticleDbContext.ConnectionStringName)
        {
                this.Configuration.ProxyCreationEnabled = false; 
            
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            // Use singular table names
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

            modelBuilder.Configurations.Add(new CategoryConfiguration());
            modelBuilder.Configurations.Add(new ArticleConfiguration());
            //modelBuilder.Configurations.Add(new OpinionConfiguration());
            //modelBuilder.Configurations.Add(new BusinessConfiguration());
            //modelBuilder.Configurations.Add(new InvestmentConfiguration());
            //modelBuilder.Configurations.Add(new JobConfiguration());
            //modelBuilder.Configurations.Add(new PositionConfiguration());
            //modelBuilder.Configurations.Add(new AdvertisementConfiguration());
            //modelBuilder.Configurations.Add(new FragmentConfiguration());
            //modelBuilder.Configurations.Add(new LinkConfiguration());
            //modelBuilder.Configurations.Add(new LinkCategoryConfiguration());
            //modelBuilder.Configurations.Add(new MessageConfiguration());

            //modelBuilder.Configurations.Add(new WorkTypeConfiguration());
            //modelBuilder.Configurations.Add(new IndustryConfiguration());
            //modelBuilder.Configurations.Add(new WorkConfiguration());

            //modelBuilder.Configurations.Add(new ProductCategoryConfiguration());
            //modelBuilder.Configurations.Add(new SerieConfiguration());
            //modelBuilder.Configurations.Add(new ShapeConfiguration());
            //modelBuilder.Configurations.Add(new TechnologyConfiguration());
            //modelBuilder.Configurations.Add(new ProductConfiguration());
            //modelBuilder.Configurations.Add(new EmailConfiguration());

            //modelBuilder.Configurations.Add(new OrderConfiguration());
            //modelBuilder.Configurations.Add(new OrderItemConfiguration());
            //modelBuilder.Configurations.Add(new ShippingMethodConfiguration());

            //modelBuilder.Configurations.Add(new ComCategoryConfiguration());
            //modelBuilder.Configurations.Add(new CommonwealConfiguration());

        }
        //public DbSet<ShippingMethod> ShippingMethods { get; set; }
        //public DbSet<OrderItem> OrderItems { get; set; }
        //public DbSet<Order> Orders { get; set; }
        //public DbSet<Email> Emails { get; set; }
        //public DbSet<Job> Jobs { get; set; }
        public DbSet<Category> Categories { get; set; }
        public DbSet<Article> Articles { get; set; }
        //public DbSet<Opinion> Opinions { get; set; }
        //public DbSet<Business> Businesses { get; set; }
        //public DbSet<Investment> Investments { get; set; }
        //public DbSet<Position> Positions { get; set; }
        //public DbSet<Advertisement> Advertisements { get; set; }
        //public DbSet<Fragment> Fragments { get; set; }
        //public DbSet<Link> Links { get; set; }
        //public DbSet<LinkCategory> LinkCategories { get; set; }
        //public DbSet<Message> Messages { get; set; }

        //public DbSet<WorkType> WorkTypes { get; set; }
        //public DbSet<Industry> Industries { get; set; }
        //public DbSet<Work> Works { get; set; }



        //public DbSet<ProductCategory> ProductCategories { get; set; }
        //public DbSet<Serie> Series { get; set; }
        //public DbSet<Shape> Shapes { get; set; }
        //public DbSet<Technology> Technologies { get; set; }
        //public DbSet<Product> Products { get; set; }
        //public DbSet<ComCategory> ComCategories { get; set; }
        //public DbSet<Commonweal> Commonweals { get; set; }
      
    }
}